function axiosGet(url, params = {}) {
    return new Promise((resolve, reject) => {
        axios({
            method: "get",
            url: url,
            params: params,
            headers: {
                'Authorization' : 'Bearer ' + localStorage.getItem("token")
            }
        }).then(response => {
            if (response.data.code != 200) {
                reject(response);
                return
            }
            resolve(response);
        }).catch(error => {
            reject(error);
        });
    });
}

function axiosPost(url, data = {}) {
    return new Promise((resolve, reject) => {
        axios({
            method: "post",
            url: url,
            data: data,
            headers: {
                'Authorization' : 'Bearer ' + localStorage.getItem("token")
            }
        }).then(response => {
            if (response.data.code != 200) {
                reject(response);
                return
            }
            resolve(response);
        }).catch(error => {
            reject(error);
        });
    });
}

function axiosPut(url, data = {}) {
    return new Promise((resolve, reject) => {
        axios({
            method: "put",
            url: url,
            data: data,
            headers: {
                'Authorization' : 'Bearer ' + localStorage.getItem("token")
            }
        }).then(response => {
            if (response.data.code != 200) {
                reject(response);
                return
            }
            resolve(response);
        }).catch(error => {
            reject(error);
        });
    });
}

function axiosDelete(url, data = {}) {
    return new Promise((resolve, reject) => {
        axios({
            method: "delete",
            url: url,
            data: data,
            headers: {
                'Authorization' : 'Bearer ' + localStorage.getItem("token")
            }
        }).then(response => {
            if (response.data.code != 200) {
                reject(response);
                return
            }
            resolve(response);
        }).catch(error => {
            reject(error);
        });
    });
}
